#include <iostream>
#include <cstring>
using namespace std;

bool is_prime(int num)
{
    int count = 0;
    for (int i = 2; i * i <= num; i++)
    {
        if (num % i == 0)
        {
            count++;
        }
    }

    if (count == 0)
    {
        return true;
    }
    else
    {
        return false;
    }
}

bool is_palindrome(int num)
{
    int temp = num;
    int reverse = 0;
    while (temp != 0)
    {
        reverse = reverse * 10 + temp % 10;
        temp /= 10;
    }

    if (reverse == num)
    {
        return true;
    }
    else
    {
        return false;
    }
}

int main()
{
    int min, max;
    cin >> min >> max;

    for (int i = min; i <= max; i++)
    {
        if (is_prime(i) && is_palindrome(i) && i != 1)
        {
            cout << i << ' ';
        }
    }

    return 0;
}
